package com.zez.controller;

import com.zez.common.util.PageResult;
import com.zez.common.util.RE;
import com.zez.entity.Student;
import com.zez.service.IStudentService;
import com.zez.vo.StudentVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zez
 * @since 2025-01-07
 */
@RestController
@RequestMapping("/student")
@CrossOrigin
public class StudentController {
    @Autowired
    private IStudentService studentService;
    @RequestMapping("/list")
    public RE getStudent(){
        return RE.ok().data("list",studentService.list());
    }
    @GetMapping("/findbypage/{page}/{pagesize}")
    public RE findbypage(@PathVariable("page")Integer page,@PathVariable("pagesize") Integer pagesize){
        PageResult<Student> aa=studentService.findbypage(page,pagesize);
        return RE.ok().data("aa",aa);
    }
    @PostMapping("/search/{page}/{pagesize}")
    public RE search(@PathVariable("page")Integer page,@PathVariable("pagesize") Integer pagesize,@RequestBody(required = false) StudentVO studentvo){
        PageResult<Student>aa=studentService.search(page,pagesize,studentvo);
        return RE.ok().data("aa",aa);
    }
}
